home *** CD-ROM | disk | FTP | other *** search
/ Programming in Microsoft Windows with C# / Programacion en Microsoft Windows con C#.iso / Original Code / Text and Fonts / HowdyWorldFullFit / HowdyWorldFullFit.cs next >
Encoding:
Text File  |  2001-01-15  |  989 b   |  31 lines

  1. //------------------------------------------------
  2. // HowdyWorldFullFit.cs ⌐ 2001 by Charles Petzold
  3. //------------------------------------------------
  4. using System;
  5. using System.Drawing;
  6. using System.Windows.Forms;
  7.  
  8. class HowdyWorldFullFit: PrintableForm
  9. {
  10.      public new static void Main()
  11.      {
  12.           Application.Run(new HowdyWorldFullFit());
  13.      }
  14.      public HowdyWorldFullFit()
  15.      {
  16.           Text = "Howdy, world!";
  17.           MinimumSize = SystemInformation.MinimumWindowSize + new Size(0,1);
  18.      }
  19.      protected override void DoPage(Graphics grfx, Color clr, int cx, int cy)
  20.      {
  21.           Font  font  = new Font("Times New Roman", 10, FontStyle.Italic);
  22.           SizeF sizef = grfx.MeasureString(Text, font);
  23.           float fScaleHorz = cx / sizef.Width;
  24.           float fScaleVert = cy / sizef.Height;
  25.  
  26.           grfx.ScaleTransform(fScaleHorz, fScaleVert);
  27.  
  28.           grfx.DrawString(Text, font, new SolidBrush(clr), 0, 0);
  29.      }
  30. }
  31.